#include "EditorEditableTextWidget.h"

#include "Widgets/RectangleWidget.h"
#include "Widgets/EditableTextWidget.h"


WHE::SEditableTextCreateResult WHE::CreateEditableTextWidget(TSharedObjectPtr<RWidget> InParentWidget)
{
    auto Background=NewWidget<RRectangleWidget>(InParentWidget);
    Background->FillColor = SColor::FromHexRGB(0x2A2A2A);
    Background->BorderColor=SColor::FromHexRGB(0x0078D4);
    Background->Radius=3;
    Background->Height=30;


    auto TextWidget=NewWidget<REditableTextWidget>(Background);
    TextWidget->Anchor.RightReference=Background;
    TextWidget->Anchor.RightOffset=5;
    TextWidget->Anchor.LeftReference=Background;
    TextWidget->Anchor.LeftOffset=5;
    TextWidget->Anchor.VerticalCenterReference=Background;
    TextWidget->Height=22;
    REditableTextWidgetWeakPtr TextWidgetWeak=TextWidget;
    Background->BorderSize=[TextWidgetWeak](){
        return TextWidgetWeak->IsEditing()?1.f:0.f;
    };

    SEditableTextCreateResult Result;
    Result.Widget=Background;
    Result.TextWidget=TextWidget;

    return Result;   
}